/**
大概意思：
 */
const target = document.getElementById('target')
const state = {
  duration: 200, 
  step:2, 
  startX: 0, 
  endX: window.innerWidth-60,
  position:0,
}
// 动画函数
function animate() {
  const {position, step, endX} = state;
  position += step;
  target.style.left = `${position}px`
  if(position > endX) {
    position = 0;
  }
  requestAnimationFrame(animate)
}
requestAnimationFrame(animate)